import { observer } from "mobx-react";
import Dialog from ".";
import { WeaTableEdit,WeaTableEditable,WeaLocaleProvider,WeaSelect } from 'ecCom';
import {toJS} from 'mobx';
import {Spin } from 'antd';
const getLabel = WeaLocaleProvider.getLabel;
@observer
export default class BeforeNodeOperateMenuDialog extends React.Component {



    render() {
        const { store } = this.props;
        const { readonly } = store;
        const columns = [
            {
                title: getLabel('506117','字段'),
                dataIndex: "fieldname",
                com: [
                // <WeaSelect
                // viewAttr={2}
                // key={"btnName"}
                // showSearch={true}
                // options={[{ key: '1', showname: '字段1' }]}
                // onChange={this.onChangeSelect}
                // />
                    {type: "select",key: "fieldname",viewAttr: 3,showSearch:true,optionFilterProp:"children",options:toJS(store.canSelectFields)}
                ],
                colSpan: 1,
                width: '50%',
            }
        ];
        const checkboxColumn   = {
            title: getLabel('502451', '默认值'),
            dataIndex: "defaultValue",
            com: [
                { type: 'input', key: 'defaultValue', multiple: (store.selectValue || []).length > 0, options: store.selectValue || [], style:{width: 220}}
            ],
            showCheckAll: true,
            checkVauleType: [1, 0],
            colSpan: 1,
            width: '50%',
        }
        if(readonly) checkboxColumn.com[0].viewAttr=1; 
        columns.push(checkboxColumn);
        
        return (
            <Dialog ecId={`${this && this.props && this.props.ecId || ''}_Dialog@9bxi33`}
                dialog={store}
                className="edc-combine-set-dialog"
            ><Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@10g97y`} spining={store.loading}>
                <WeaTableEditable ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEditable@c3r4f0`}
                    title={getLabel('513395','设置默认值')}
                    columns={columns}
                    className={'beforenodeoperate-ant-table-body'}
                    datas={toJS(store.tableDatas)}
                    showTitle={true}
                    draggable={false}
                    showCopy={false}
                    willAdd={store.willAddDatas}
                    //getRowSelection={()=>null}
                    cells={toJS(store.cells)}
                    onChange={(a,b,c,d) => store.setTableDatas(a,b,c,d)}
                    tableProps={{
                        scroll: { y: 408}
                    }}
                />
                </Spin>
            </Dialog>
        )
    }

    onChangeSelect =(value,tableCellProps,b,c,d) => {

        console.log("00,",value,tableCellProps,b,c,d);

    }


}